package de.hwrberlin.remo.diagram.properties;

import org.eclipse.gmf.runtime.diagram.ui.properties.sections.AbstractModelerPropertySection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;

import de.hwrberlin.expertsystem.util.ModelEditingHelper;
import de.hwrberlin.remo.diagram.edit.parts.RemoObjectEditPart;

public class AbstractRemoPropertySection extends AbstractModelerPropertySection {
	
	protected ModelEditingHelper editingHelper;
	
	public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);
		
		if(editingHelper == null) {
			editingHelper = new ModelEditingHelper(getEditingDomain());
		}
		
		if (!selection.isEmpty() && selection instanceof StructuredSelection) {
			StructuredSelection strucSelection = (StructuredSelection) selection;
					
			if (strucSelection.getFirstElement() instanceof  RemoObjectEditPart) {
				RemoObjectEditPart editPart = (RemoObjectEditPart) strucSelection.getFirstElement();
				setEObject(editPart.getRemoObject());
			}
			
		}
	}
}
